<template>
	<view class="page">
		<u-sticky>
			<u-tabs @change="Ctabs" active-color="#00C08D" :list="tabs" :is-scroll="false" :current="current"></u-tabs>
		</u-sticky>
		
		<wr-book  @pay="pay" @close="close" :isTechnician="0" :list="list"></wr-book>
		
		
		 <u-loadmore :status="initial.status" />
		 
		 
	</view>
</template>

<script>
	import wxpay from '@/common/wxpay.js';
	import loader from '@/common/loadPage.js';
	export default {
		mixins: [loader],
		data() {

			return {
				tabs: [{
					name: "全部"
				}, {
					name: "待付款"
				}, {
					name: "待接单"
				}, {
					name: "进行中"
				}, {
					name: "已完成"
				}],
				current: 0,
				list: [],
				initial: {
					geturl: "/user/getOrderList",
					parm: {
						is_pay_type: '',
						status: ''
					},
					isPage: true
				},
			}
		},
		async onShow() {
             this.jiazai()
		},
		methods: {
		close(item){
			
				this.$u.post('/order/setOrderStatus', {
					trade_no: item.trade_no,
					status: 6
				}).then(res => {
					uni.navigateTo({
						url:"./detail?id="+item.trade_no
					})
				}).catch(err => {})
			
			
		},
			jiazai(){
				this.getGoods().then(res=>{
					let arr = [];
					res.forEach(item=>{
						item.project_info.images= item.project_info.images.split(",") 
						
					});
					this.list = res;
				})
			},
			
			
			pay(item){
				this.$u.post('/pay/submitOrder', {
				    trade_no:item.trade_no
				}).then(res => {
					const wx=new wxpay(res);
					wx.pay().then(res=>{
						  uni.navigateTo({
						  	url:"./detail?id="+item.trade_no
						  })
					}).catch(err=>{
						uni.navigateBack({
							
						})
					})
			
				}).catch(err => {})
		
			},
		
		
			
			Ctabs(e) {
				this.current = e;
				this.initial.page=1;
				if(e==0){
					this.initial.parm.is_pay_type=''
					this.initial.parm.status=''
					
				}
				if(e==1){
					this.initial.parm.is_pay_type=0;
					this.initial.parm.status=''
				}
				if(e==2){
					this.initial.parm.is_pay_type=1;
					this.initial.parm.status=0
				}
				if(e==3){
					this.initial.parm.is_pay_type=1
					this.initial.parm.status="1,4"
				}
				if(e==4){
					this.initial.parm.is_pay_type=1
					this.initial.parm.status=5
				}
				this.jiazai()
			},

		}
	}
</script>


<style>
	.page {
		background: #F1F1F1;
		min-height: 100vh;
	}

	.list {
		background: #fff;
		width: 700rpx;
		margin: 20rpx auto;
		padding: 20rpx;
		border-radius: 20rpx;
	}
</style>
